package com.htj.bookreview.contorller;

import com.htj.bookreview.entity.User;
import com.htj.bookreview.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;


@Controller
public class LoginController {
    @Autowired
    UserService userService;
    @RequestMapping("/index")
    public String show(){
        return "admin/header";
    }

    @RequestMapping(value = "/login",method = RequestMethod.POST)
    public String login(String name, String password){
        User user = userService.loginIn(name,password);
        if (user!=null){
            return "Index3";
        }else {
            return "error/404";
        }
    }
}